package com.cwt_taxi_xa;

import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;

import com.cwt_taxi_xa.constants.SPConstants;
import com.cwt_taxi_xa.protocol.MCUUtil;
import com.cwt_taxi_xa.util.AppLog;
import com.cwt_taxi_xa.util.SPUtils;

public class ActivityVolume extends CWTBaseActivity implements SeekBar.OnSeekBarChangeListener {

	final static String TAG = "ActivityFMConfig";

	SeekBar sbMain,sbVoice;
	TextView txMain,txVoice;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		openSwipeBack(true);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_volume_config);
		AppLog.d(TAG, "onCreate");

		sbMain = (SeekBar)findViewById(R.id.sb_volume_main);
		sbVoice = (SeekBar)findViewById(R.id.sb_volume_voice);

		txMain = (TextView)findViewById(R.id.tv_volume_main);
		txVoice = (TextView)findViewById(R.id.tv_volume_voice);

		sbMain.setOnSeekBarChangeListener(this);
		sbVoice.setOnSeekBarChangeListener(this);

		sbMain.setMax(25);
		sbVoice.setMax(25);

		sbMain.setProgress(SPUtils.getParamInteger(SPConstants.SPK_vol, SPConstants.SPV_vol));
		sbVoice.setProgress(SPUtils.getParamInteger(SPConstants.SPK_vol_voice, SPConstants.SPV_vol_voice));
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		AppLog.d(TAG,"onResume");
	}
	
	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	public void setStatus(int index, boolean status) {

	}

	@Override
	public void sendMsg(int type, Object obj) {
		// TODO Auto-generated method stub
		AppLog.d(TAG,"sendMsg type:" + type);

	}


	@Override
	public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

		switch (seekBar.getId()){
			case R.id.sb_volume_main:
				txMain.setText(String.valueOf(progress));
				break;
			case R.id.sb_volume_voice:
				txVoice.setText(String.valueOf(progress));
				break;
		}
	}

	@Override
	public void onStartTrackingTouch(SeekBar seekBar) {

	}

	@Override
	public void onStopTrackingTouch(SeekBar seekBar) {
		switch (seekBar.getId()){
			case R.id.sb_volume_main:
				MCUUtil.setvol(seekBar.getProgress(),"音量设置界面");
				break;
			case R.id.sb_volume_voice:
				SPUtils.setParam(SPConstants.SPK_vol_voice,seekBar.getProgress());
				break;
		}

	}

}
